home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 348 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  57 lines

  1. Path: rose_ip167.efn.org!peterf
  2. From: peterf@gears.efn.org (Peter F.)
  3. Newsgroups: comp.lang.c++
  4. Subject: Binaries
  5. Date: Tue, 2 Jan 1996 23:18:34
  6. Organization: Southern Oregon Unified Networking District (SOUND)
  7. Message-ID: <peterf.58.00174FE2@gears.efn.org>
  8. NNTP-Posting-Host: rose_ip167.efn.org
  9. X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
  10.  
  11. Dear Friends,
  12.  
  13. I have been working on a c++ program, where the goal is to imitate the dos 
  14. copy command.  I have been writing this program, and it works eccept for one 
  15. small thing.  When I read a file, say 29,300 bytes and then want to output 
  16. that file to a new directory, the files always come out 1 byte larger (ex. 
  17. 29,301).  I dont know where the extra byte is coming from? Here is the code 
  18. and maybe you could find the problem....
  19.  
  20. #include <stdio.h>
  21.  
  22. void main(void)
  23.  {
  24.    FILE *in, *out;
  25.  
  26.    if ((in = fopen("C:\\car.pcx", "rb"))== NULL)
  27.     {
  28.      fprintf(stderr, "Cannot open input file.\n");
  29.     }
  30.  
  31.    if ((out = fopen("C:\\temp\\car.pcx", "wb"))== NULL)
  32.     {
  33.      fprintf(stderr, "Cannot open output file.\n");
  34.     }
  35.  
  36.    while (!feof(in))
  37.     { fputc(fgetc(in), out); }
  38.  
  39.    fclose(in);
  40.    fclose(out);
  41.  }
  42.  
  43. I compiled this code, and when I tried to view the car.pcx file in the temp 
  44. dir. it was the same image, but the colors had changed.  I am worried with 
  45. this extra byte that it may mess up .exe or .dll files when copied.
  46. Also if anyone knows how to access Dos commands like copy or move from C++ 
  47. this could help also.  I use BC++ 3.1.
  48.  
  49. P.S. -- Anyone know how the copy command works, like how it keeps the same 
  50. date, time, file size, of the target file you copied from.
  51.  
  52. Thanks,
  53.  
  54. Peter Felten
  55.  
  56. peterf@gears.efn.org
  57.